import 'dart:convert';

import 'package:json_annotation/json_annotation.dart';

part 'SendMsgModel.g.dart';

@JsonSerializable()
class SendMsgModel {
  @JsonKey(name: 'fromId')
  int _fromId;
  @JsonKey(name: 'msg')
  String _msg;
  @JsonKey(name: 'avatarUrl')
  String _avatarUrl;
  @JsonKey(name: 'isSelf')
  bool _isSelf;

  SendMsgModel({int? fromId, String? msg, String? avatarUrl, bool? isSelf})
      : _fromId = fromId ?? 0,
        _msg = msg ?? '',
        _avatarUrl = avatarUrl ?? '',
        _isSelf = isSelf ?? false;

  String get msg => _msg;

  set msg(String value) {
    _msg = value;
  }

  String get avatarUrl => _avatarUrl;

  set avatarUrl(String value) {
    _avatarUrl = value;
  }

  bool get isSelf => _isSelf;

  set isSelf(bool value) {
    _isSelf = value;
  }

  int get fromId => _fromId;

  set fromId(int value) {
    _fromId = value;
  }

  SendMsgModel.fromJson(Map<String, dynamic> json)
      : _fromId = json['fromId'],
        _msg = json['msg'],
        _avatarUrl = json['avatarUrl'],
        _isSelf = json['isSelf'];

  Map<String, dynamic> toJson() => _$SendMsgModelToJson(this);
}
